<?php


abstract class BasesfPatientPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'sf_patient';

	
	const CLASS_DEFAULT = 'lib.model.sfPatient';

	
	const NUM_COLUMNS = 25;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'sf_patient.ID';

	
	const NOM = 'sf_patient.NOM';

	
	const PRENOM = 'sf_patient.PRENOM';

	
	const SEXE = 'sf_patient.SEXE';

	
	const NATIONALITE = 'sf_patient.NATIONALITE';

	
	const ADRESSE = 'sf_patient.ADRESSE';

	
	const CODE_POSTAL = 'sf_patient.CODE_POSTAL';

	
	const VILLE = 'sf_patient.VILLE';

	
	const PAYS = 'sf_patient.PAYS';

	
	const TEL_FIXE = 'sf_patient.TEL_FIXE';

	
	const TEL_PORTABLE = 'sf_patient.TEL_PORTABLE';

	
	const PROFESSION = 'sf_patient.PROFESSION';

	
	const INCAPACITE_MAJEUR = 'sf_patient.INCAPACITE_MAJEUR';

	
	const NUM_SECU_SOCIALE = 'sf_patient.NUM_SECU_SOCIALE';

	
	const NOM_A_PREVENIR = 'sf_patient.NOM_A_PREVENIR';

	
	const PRENOM_A_PREVENIR = 'sf_patient.PRENOM_A_PREVENIR';

	
	const TEL_A_PREVENIR = 'sf_patient.TEL_A_PREVENIR';

	
	const REMARQUES = 'sf_patient.REMARQUES';

	
	const TAILLE = 'sf_patient.TAILLE';

	
	const POIDS = 'sf_patient.POIDS';

	
	const RENSEI_PRESCRI = 'sf_patient.RENSEI_PRESCRI';

	
	const NOM_MEDECIN_TRAIT = 'sf_patient.NOM_MEDECIN_TRAIT';

	
	const ADR_MEDECIN_TRAIT = 'sf_patient.ADR_MEDECIN_TRAIT';

	
	const TEL_MEDECIN_TRAIT = 'sf_patient.TEL_MEDECIN_TRAIT';

	
	const CMU = 'sf_patient.CMU';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'Nom', 'Prenom', 'Sexe', 'Nationalite', 'Adresse', 'CodePostal', 'Ville', 'Pays', 'TelFixe', 'TelPortable', 'Profession', 'IncapaciteMajeur', 'NumSecuSociale', 'NomAPrevenir', 'PrenomAPrevenir', 'TelAPrevenir', 'Remarques', 'Taille', 'Poids', 'RenseiPrescri', 'NomMedecinTrait', 'AdrMedecinTrait', 'TelMedecinTrait', 'Cmu', ),
		BasePeer::TYPE_COLNAME => array (sfPatientPeer::ID, sfPatientPeer::NOM, sfPatientPeer::PRENOM, sfPatientPeer::SEXE, sfPatientPeer::NATIONALITE, sfPatientPeer::ADRESSE, sfPatientPeer::CODE_POSTAL, sfPatientPeer::VILLE, sfPatientPeer::PAYS, sfPatientPeer::TEL_FIXE, sfPatientPeer::TEL_PORTABLE, sfPatientPeer::PROFESSION, sfPatientPeer::INCAPACITE_MAJEUR, sfPatientPeer::NUM_SECU_SOCIALE, sfPatientPeer::NOM_A_PREVENIR, sfPatientPeer::PRENOM_A_PREVENIR, sfPatientPeer::TEL_A_PREVENIR, sfPatientPeer::REMARQUES, sfPatientPeer::TAILLE, sfPatientPeer::POIDS, sfPatientPeer::RENSEI_PRESCRI, sfPatientPeer::NOM_MEDECIN_TRAIT, sfPatientPeer::ADR_MEDECIN_TRAIT, sfPatientPeer::TEL_MEDECIN_TRAIT, sfPatientPeer::CMU, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'nom', 'prenom', 'sexe', 'nationalite', 'adresse', 'code_postal', 'ville', 'pays', 'tel_fixe', 'tel_portable', 'profession', 'incapacite_majeur', 'num_secu_sociale', 'nom_a_prevenir', 'prenom_a_prevenir', 'tel_a_prevenir', 'remarques', 'taille', 'poids', 'rensei_prescri', 'nom_medecin_trait', 'adr_medecin_trait', 'tel_medecin_trait', 'cmu', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nom' => 1, 'Prenom' => 2, 'Sexe' => 3, 'Nationalite' => 4, 'Adresse' => 5, 'CodePostal' => 6, 'Ville' => 7, 'Pays' => 8, 'TelFixe' => 9, 'TelPortable' => 10, 'Profession' => 11, 'IncapaciteMajeur' => 12, 'NumSecuSociale' => 13, 'NomAPrevenir' => 14, 'PrenomAPrevenir' => 15, 'TelAPrevenir' => 16, 'Remarques' => 17, 'Taille' => 18, 'Poids' => 19, 'RenseiPrescri' => 20, 'NomMedecinTrait' => 21, 'AdrMedecinTrait' => 22, 'TelMedecinTrait' => 23, 'Cmu' => 24, ),
		BasePeer::TYPE_COLNAME => array (sfPatientPeer::ID => 0, sfPatientPeer::NOM => 1, sfPatientPeer::PRENOM => 2, sfPatientPeer::SEXE => 3, sfPatientPeer::NATIONALITE => 4, sfPatientPeer::ADRESSE => 5, sfPatientPeer::CODE_POSTAL => 6, sfPatientPeer::VILLE => 7, sfPatientPeer::PAYS => 8, sfPatientPeer::TEL_FIXE => 9, sfPatientPeer::TEL_PORTABLE => 10, sfPatientPeer::PROFESSION => 11, sfPatientPeer::INCAPACITE_MAJEUR => 12, sfPatientPeer::NUM_SECU_SOCIALE => 13, sfPatientPeer::NOM_A_PREVENIR => 14, sfPatientPeer::PRENOM_A_PREVENIR => 15, sfPatientPeer::TEL_A_PREVENIR => 16, sfPatientPeer::REMARQUES => 17, sfPatientPeer::TAILLE => 18, sfPatientPeer::POIDS => 19, sfPatientPeer::RENSEI_PRESCRI => 20, sfPatientPeer::NOM_MEDECIN_TRAIT => 21, sfPatientPeer::ADR_MEDECIN_TRAIT => 22, sfPatientPeer::TEL_MEDECIN_TRAIT => 23, sfPatientPeer::CMU => 24, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nom' => 1, 'prenom' => 2, 'sexe' => 3, 'nationalite' => 4, 'adresse' => 5, 'code_postal' => 6, 'ville' => 7, 'pays' => 8, 'tel_fixe' => 9, 'tel_portable' => 10, 'profession' => 11, 'incapacite_majeur' => 12, 'num_secu_sociale' => 13, 'nom_a_prevenir' => 14, 'prenom_a_prevenir' => 15, 'tel_a_prevenir' => 16, 'remarques' => 17, 'taille' => 18, 'poids' => 19, 'rensei_prescri' => 20, 'nom_medecin_trait' => 21, 'adr_medecin_trait' => 22, 'tel_medecin_trait' => 23, 'cmu' => 24, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/sfPatientMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.sfPatientMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = sfPatientPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(sfPatientPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(sfPatientPeer::ID);

		$criteria->addSelectColumn(sfPatientPeer::NOM);

		$criteria->addSelectColumn(sfPatientPeer::PRENOM);

		$criteria->addSelectColumn(sfPatientPeer::SEXE);

		$criteria->addSelectColumn(sfPatientPeer::NATIONALITE);

		$criteria->addSelectColumn(sfPatientPeer::ADRESSE);

		$criteria->addSelectColumn(sfPatientPeer::CODE_POSTAL);

		$criteria->addSelectColumn(sfPatientPeer::VILLE);

		$criteria->addSelectColumn(sfPatientPeer::PAYS);

		$criteria->addSelectColumn(sfPatientPeer::TEL_FIXE);

		$criteria->addSelectColumn(sfPatientPeer::TEL_PORTABLE);

		$criteria->addSelectColumn(sfPatientPeer::PROFESSION);

		$criteria->addSelectColumn(sfPatientPeer::INCAPACITE_MAJEUR);

		$criteria->addSelectColumn(sfPatientPeer::NUM_SECU_SOCIALE);

		$criteria->addSelectColumn(sfPatientPeer::NOM_A_PREVENIR);

		$criteria->addSelectColumn(sfPatientPeer::PRENOM_A_PREVENIR);

		$criteria->addSelectColumn(sfPatientPeer::TEL_A_PREVENIR);

		$criteria->addSelectColumn(sfPatientPeer::REMARQUES);

		$criteria->addSelectColumn(sfPatientPeer::TAILLE);

		$criteria->addSelectColumn(sfPatientPeer::POIDS);

		$criteria->addSelectColumn(sfPatientPeer::RENSEI_PRESCRI);

		$criteria->addSelectColumn(sfPatientPeer::NOM_MEDECIN_TRAIT);

		$criteria->addSelectColumn(sfPatientPeer::ADR_MEDECIN_TRAIT);

		$criteria->addSelectColumn(sfPatientPeer::TEL_MEDECIN_TRAIT);

		$criteria->addSelectColumn(sfPatientPeer::CMU);

	}

	const COUNT = 'COUNT(sf_patient.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT sf_patient.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(sfPatientPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(sfPatientPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = sfPatientPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = sfPatientPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return sfPatientPeer::populateObjects(sfPatientPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			sfPatientPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = sfPatientPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return sfPatientPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(sfPatientPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(sfPatientPeer::ID);
			$selectCriteria->add(sfPatientPeer::ID, $criteria->remove(sfPatientPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(sfPatientPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(sfPatientPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof sfPatient) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(sfPatientPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(sfPatient $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(sfPatientPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(sfPatientPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(sfPatientPeer::DATABASE_NAME, sfPatientPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = sfPatientPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(sfPatientPeer::DATABASE_NAME);

		$criteria->add(sfPatientPeer::ID, $pk);


		$v = sfPatientPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(sfPatientPeer::ID, $pks, Criteria::IN);
			$objs = sfPatientPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BasesfPatientPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/sfPatientMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.sfPatientMapBuilder');
}
